<%@page import="entity.Member"%>
<%@page import="dao.MemberDao"%>
<%@page import="service.FindDiscuss"%>
<%@page import="entity.Discuss"%>
<%@page import="java.util.List"%>
<%@page import="dao.BookDao"%>
<%@page import="entity.Book"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" charset="utf-8" />
    </head>
    <body>
        <%
            int bookId=Integer.parseInt(request.getParameter("bookid"));
            Book book=new BookDao().getBookById(bookId);
            
        %>
        <div class="container">
            <h1 class="text-primary text-center">图书信息</h1>
            <h3 ><%=book.getBookName()%></h3>
            <div>
                <img src="img/<%=book.getCover()%>" style="border-radius: 10px" width="220px" height="300px" alt="<%=book.getBookName()%>">
            </div>
            <div style="width: 300px;height:250px;position:absolute;left:800px;top:130px" >
                <p>编号：<%=book.getId()%></p>
                <p>作者：<%=book.getAuthor()%></p>
                <p>出版日期：<%=book.getPublishDate()%></p>
                <p>出版社：<%=book.getPublishHouse()%></p>
                <p>类型：<%=book.getType()%></p>
            </div>
            <div style="width:400px;word-wrap: break-word">
                <p>简介：<%=book.getIntroduction()%></p>
                <p style="font-size: 18px">评分：<%=book.getMark()%>分</p>
            </div>
            <div style="width:400px;word-wrap: break-word"> 
                <p style="font-size: 18px">评论：</p>
                <%
                    List<Discuss> list=new FindDiscuss().findDiscussByBookId(book.getId());
                    for(Discuss discuss:list){
                        Member member=new MemberDao().getMemberById(discuss.getMemberId());

                %>
                <p style="font-size: 18px"><%=member.getName()%>:<%=discuss.getComment()%></p>
                <%
                    }
                %>
            </div>       
            <h1 style="position: absolute;left:950px;top:100px">单价：<%=book.getPrice()%>元</h1>
        </div>
    </body>
</html>
